/**
 * gpms
 * 2012-8-1 下午3:02:15
 * 作者：陈志明
 * 
 */
package com.gpms.privilege.dao;

import java.util.List;

import com.gpms.common.dao.BaseDaoSupport;
import com.gpms.mapper.*;

/**
 * @author Jackie chen
 *
 */
public class RoleDao extends BaseDaoSupport {
	
	/**
	 * 查询所有角色
	 * @return
	 */
	public List<Role> findAllRole(){
		return this.getSqlSession().selectList(roleMapper+".selectAllRole");
	}
	
	/**
	 * 根据ID查询角色
	 * @return
	 */
	public Role findRoleById(Role role){
		return this.getSqlSession().selectOne(roleMapper+".selectByPrimaryKey",role.getId());
	}
	
	/**
	 * 保存角色
	 * @param role
	 * @return
	 */
	public int saveRole(Role role){
		return this.getSqlSession().insert(roleMapper+".insertSelective", role);
	}
	
	/**
	 * 根据ID修改角色
	 * @param role
	 * @return
	 */
	public int alterRoleById(Role role){
		return this.getSqlSession().update(roleMapper+".updateByPrimaryKeySelective", role);
	}
	
	/**
	 * 根据ID删除角色
	 * @param role
	 * @return
	 */
	public int removeRoleById(Role role){
		return this.getSqlSession().delete(roleMapper+".deleteByPrimaryKey", role.getId());
	}
}
